using System;
using System.Collections.Generic;
using System.Text;

namespace dender.dvdcover.core
{
    /// <summary>
    /// Defines an entity that has a dimension
    /// </summary>
    public abstract class DimensionBase
    {
        private float mHeight;
        /// <summary>
        /// Gets or sets the height of the format
        /// </summary>
        /// <exception cref="System.ArgumentException">
        /// Throws an Argument exception if the height is smaller or equal to zero
        /// </exception>
        public float Height
        {
            get { return mHeight; }
            set
            {
                if (value <= 0)
                    throw new ArgumentException("Height");

                mHeight = value;
            }
        }

        private float mWidth;
        /// <summary>
        /// Gets or sets the width of the format
        /// </summary>
        /// <exception cref="System.ArgumentException">
        /// Throws an Argument exception if the with is smaller or equal to zero
        /// </exception>
        public float Width
        {
            get { return mWidth; }
            set
            {
                if (value <= 0)
                    throw new ArgumentException("Width");
                mWidth = value;
            }
        }

        /// <summary>
        /// Gets the aspectratio of the cover, this is width over height
        /// </summary>
        public float AspectRatio
        {
            get { return Width / Height; }
        }

        /// <summary>
        /// Creates a DimensionBase
        /// </summary>
        public DimensionBase()
        {

        }

         /// <summary>
        /// Creates a DimensionBase, initializeing width and height
        /// </summary>
        /// <param name="width">Width of the CoverBase</param>
        /// <param name="height">Heigh of the CoverBase</param>
        /// <exception cref="System.ArgumentException">
        /// Throws an argument exception if width or heigh are less then or equal
        /// to zero
        /// </exception>
        public DimensionBase(float width, float height) : this()
        {
            this.Width = width;
            this.Height = height;
        }

        /// <summary>
        /// Copy Constructor
        /// </summary>
        /// <param name="dimensionBase">DimensionBase to copy</param>
        public DimensionBase(DimensionBase dimensionBase)
        {
            this.Width = dimensionBase.Width;
            this.Height = dimensionBase.Height;
        }
    }
}
